<html>
<head>
<script>
	function fake_handler(tab) {
		//chrome.tabs.executeScript(tab.id, {file:"fake.js"});
		var title;
		if (localStorage.customTitle)
			title = localStorage.customTitle;
		else
			title = "Google";

		var favicon;
		if (localStorage.customFavicon) {
			favicon = localStorage.customFavicon;
			
			if(favicon.substring(0, 7) != "http://")
				favicon = "http://" + favicon + "/favicon.ico";
		}
		else
			favicon = "http://www.google.com/favicon.ico";
		
		console.debug("title:" + title);
		console.debug("favicon:" + favicon);
			
		var fake_code;
		fake_code = "document.title = \"";
		fake_code += title;
		fake_code += "\";";
		fake_code += "newIcon = document.createElement(\"link\");";
		fake_code += "newIcon.type = \"image/icon\";"
		fake_code += "newIcon.rel = \"shortcut icon\";"
		fake_code += "newIcon.href = \"";
		fake_code += favicon;
		fake_code += "\";"
		fake_code += "document.head.appendChild(newIcon);"
		chrome.tabs.executeScript(tab.id, {code:fake_code});
	}

	chrome.browserAction.onClicked.addListener(fake_handler);
</script>
</head>
</html>